﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "GmPositioningElements.h"
#include "NdbObjectSchematic.h"
#include "NdbDataSchema.h"

namespace gcmp
{
    class GM_POSITIONING_ELEMENTS_EXPORT LeaderOffset : public NdbObjectSchematic
    {
        DATA_BEGIN(gcmp, LeaderOffset, gcmp::NdbObjectSchematic, C43C9DCB - EC59 - 4268 - B0EB - D4AC69399C85, gmpositioningelements)
            
            // 侧向偏移约定：按照轴网start->end方向，左偏为负，右偏为正
            // 轴向偏移约定：按照轴网start->end方向，start->end为正，反之为负
            
            DATA(double, TerminalTraverseOffset)  // 轴网部分：端部侧向偏移
            DATA(double, ElbowAxisOffset)  // 轴网部分：肘部轴向偏移
            DATA(double, AnchorAxisOffset)  // 轴网部分：锚部轴向偏移
            
            // todo 弯头部分：端部轴向偏移
            // todo 弯头部分：端部侧向偏移

        DATA_END
    public:
        virtual ~LeaderOffset() {}

        double GetTerminalTraverseOffset() const { return this->GetTerminalTraverseOffset__(); }
        bool SetTerminalTraverseOffset(double val) { this->SetTerminalTraverseOffset__(val); return true; }

        double GetElbowAxisOffset() const { return this->GetElbowAxisOffset__(); }
        bool SetElbowAxisOffset(double val) { this->SetElbowAxisOffset__(val); return true; }

        double GetAnchorAxisOffset() const { return this->GetAnchorAxisOffset__(); }
        bool SetAnchorAxisOffset(double val) { this->SetAnchorAxisOffset__(val); return true; }

    public: //实现NdbObject接口
        virtual NdbObject* GetTopOwnerObject() const override
        {
            return nullptr;
        }
    };

    class GM_POSITIONING_ELEMENTS_EXPORT LeaderInfo : public NdbObjectSchematic
    {
        DATA_BEGIN(gcmp, LeaderInfo, gcmp::NdbObjectSchematic, 27E45F5A - 46D8 - 46DE - B08E - 1B6D26468E3E, gmpositioningelements)
            DATA(LeaderOffset, StartLeader)
            DATA(LeaderOffset, EndLeader)
        DATA_END
    public:
        virtual ~LeaderInfo() {}

        LeaderOffset GetStartLeader() const { return this->GetStartLeader__(); }
        bool SetStartLeader(const LeaderOffset& val) { this->SetStartLeader__(val); return true; }
        LeaderOffset GetEndLeader() const { return this->GetEndLeader__(); }
        bool SetEndLeader(const LeaderOffset& val) { this->SetEndLeader__(val); return true; }

    public: //实现NdbObject接口
        virtual NdbObject* GetTopOwnerObject() const override
        {
            return nullptr;
        }
    };

    class GM_POSITIONING_ELEMENTS_EXPORT Leaders : public NdbObjectSchematic
    {
        DATA_BEGIN(gcmp, Leaders, gcmp::NdbObjectSchematic, 7BF7116E - 7022 - 4976 - A151 - A40DFE4D65AF, gmpositioningelements)
            UMAP_DATA(ElementId, LeaderInfo, ElementIdHash, LocalLeaderInfo) // 视图重载弯头参数
        DATA_END
    public:
        virtual ~Leaders() {}

    public: //实现NdbObject接口
        virtual NdbObject* GetTopOwnerObject() const override
        {
            return nullptr;
        }
    };

}// namespace gcmp
